﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Template2.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EnglishAuction.Default" %>

<%@ Register Assembly="CollectionPager" Namespace="SiteUtils" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    Trang chủ
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <form id="form1" runat="server" style="width: 100%; margin: 0 auto;">
        <script type="text/javascript">
            var thoiGian = <%=JsonDate%>;
            function cdtd() {
                for (i = 0; i < thoiGian.length; i++) {
                  
                    var xmas = new Date(thoiGian[i]);
                    var now = new Date();
                    var timeDiff = xmas.getTime() - now.getTime();
                    if (timeDiff <= 0) {
                        clearTimeout(timer);
                        document.getElementById("txtCountdown" + (i + 1).toString()).innerHTML = "<span style='color:#E28D00;'>Sản phẩm hết hạn đấu giá.</span>";
                        //document.write("Christmas is here!");
                        // Run any code needed for countdown completion here
                        //window.location.reload();
                    }
                    else {
                        var seconds = Math.floor(timeDiff / 1000);
                        var minutes = Math.floor(seconds / 60);
                        var hours = Math.floor(minutes / 60);
                        var days = Math.floor(hours / 24);
                        hours %= 24;
                        minutes %= 60;
                        seconds %= 60;

                        var s = "";
                        if(days != 0) {
                            s += "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + days + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> ngày </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + hours + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giờ </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + minutes  + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giây </span>";
                        }
                        else if(hours != 0) {
                            s = "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + hours + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giờ </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + minutes  + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giây </span>";
                        }
                        else if(minutes != 0) {
                            s = "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + minutes  + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> phút </span>" + "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giây </span>";
                        }
                        else {
                            s = "<span style='color:#E28D00;font-weight:bold;font-size:16px;'>" + seconds + "</span>" + "<span style='color:#E28D00; font-size:11px; padding-top:-5px;'> giây </span>";
                        }

                        document.getElementById("txtCountdown" + (i + 1).toString()).innerHTML = s;
                    }
                    
                }
                var timer = setTimeout('cdtd()', 1000);

            }
        </script>

        <span style="color: #666; font-size: 16px; font-weight: bold; display: inline-block; margin: 5px; margin-left: 15px;">*Sản phẩm đang đấu giá</span>

        <asp:DataList ID="dtlSanPhamDauGia" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" ShowFooter="False" ShowHeader="False" Width="100%" Style="margin: 0 auto;" CellPadding="5" CellSpacing="2">
            <ItemTemplate>
                <div style="width: 350px; background: #fff; border: solid 1px #ccc; height: 140px;">
                    <div style="float: left; width: 140px;">
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "DetailsProduct.aspx?Id="+Eval("Id") %>'>
                            <asp:Image Width="120px" Height="120px" ImageUrl='<%# "~/images/"+Eval("HinhAnh") %>' runat="server" ImageAlign="AbsMiddle" style="margin:10px;border: solid 1px #ccc;"/>
                        </asp:HyperLink>
                    </div>
                    <div>
                        <div style="padding-top: 10px;">
                            <div style="color: #0072BC; font-weight: bold; font-size: 15px;">
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("TenSanPham") %>'></asp:Label>
                            </div>
                            <div style="margin-top: 8px;">
                                Giá sàn:
                            <asp:Label ID="Label2" runat="server" Style="font-weight: bold;" Text='<%# Eval("GiaSan", "{0:###,###}")+" (VNÐ)" %>'></asp:Label>
                            </div>
                            <div style="margin-top: 8px;">
                                Kết thúc: <strong><%# String.Format("{0:hh:mm tt dd/MM/yyyy}", DateTime.Parse(Eval("NgayLenSan").ToString()).Add(new System.TimeSpan(int.Parse(Eval("ThoiGianDauGia").ToString()),0,0,0))) %></strong>
                            </div>
                            <div style="margin-top: 8px;">
                                <%# Eval("Countdown") %>
                            </div>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:DataList>
        <div class="phantrang">
            <cc1:CollectionPager ID="pagerSanPhamDauGia" runat="server"></cc1:CollectionPager>
        </div>


        <div style="background-color: #FBC701; height: 4px; margin: auto; width: 100%; border: 1px solid #F1AD1E; margin-bottom: 15px;"></div>
        <span style="color: #666; font-size: 16px; font-weight: bold; display: inline-block; margin: 5px; margin-left: 15px;">*Sản phẩm đã đấu</span>

        <asp:DataList ID="dtlSanPhamDaDau" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" ShowFooter="False" ShowHeader="False" Width="100%" Style="margin: 0 auto;" CellPadding="5" CellSpacing="2">
            <ItemTemplate>
                <div style="width: 350px; background: #fff; border: solid 1px #ccc; height: 140px;">
                    <div style="float: left; width: 140px;">
                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "DetailsProduct.aspx?Id="+Eval("Id") %>'>
                            <asp:Image ID="Image1" Width="120px" Height="120px" ImageUrl='<%# "~/images/"+Eval("HinhAnh") %>' runat="server" ImageAlign="AbsMiddle" Style="margin: 10px; border: solid 1px #ccc;" />
                        </asp:HyperLink>
                    </div>
                    <div>
                        <div style="padding-top: 10px;">
                            <div style="color: #0072BC; font-weight: bold; font-size: 15px;">
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("TenSanPham") %>'></asp:Label>
                            </div>
                            <div style="margin-top: 8px;">
                                Giá sàn:
                            <asp:Label ID="Label2" runat="server" Style="font-weight: bold;" Text='<%# Eval("GiaSan", "{0:###,###}")+" VNÐ" %>'></asp:Label>
                            </div>
                            <div style="margin-top: 8px;">
                                Kết thúc: <strong><%# String.Format("{0:hh:mm dd/MM/yyyy}",DateTime.Parse(Eval("NgayLenSan").ToString()).Add(new System.TimeSpan(int.Parse(Eval("ThoiGianDauGia").ToString()),0,0,0))) %></strong>
                            </div>
                            <div style="margin-top: 8px;">
                                <%# Eval("GiaThang") %>
                            </div>
                        </div>
                    </div>
                </div>
            </ItemTemplate>
        </asp:DataList>
        <div class="phantrang">
            <cc1:CollectionPager ID="pagerSanPhamDaDau" runat="server"></cc1:CollectionPager>
        </div>

    </form>
    <script>cdtd();</script>
</asp:Content>
